using System;
using Orm;

namespace ormsamples {
	public class CreatePetShopData {
		private void CreateData() {
			PersistentTransaction t = petshop.PetShopPersistentManager.Instance().GetSession().BeginTransaction();
			try {
				petshop.Pet lpetshopPet = petshop.PetFactory.CreatePet();
				// Initialize the properties of the persistent object here
				lpetshopPet.Save();
				petshop.Transaction lpetshopTransaction = petshop.TransactionFactory.CreateTransaction();
				// TODO Initialize the properties of the persistent object here, the following properties must be initialized before saving : customer, staff, price
				lpetshopTransaction.Save();
				petshop.Customer lpetshopCustomer = petshop.CustomerFactory.CreateCustomer();
				// TODO Initialize the properties of the persistent object here, the following properties must be initialized before saving : transaction
				lpetshopCustomer.Save();
				petshop.Staff lpetshopStaff = petshop.StaffFactory.CreateStaff();
				// TODO Initialize the properties of the persistent object here, the following properties must be initialized before saving : transaction
				lpetshopStaff.Save();
				t.Commit();
			}
			catch(Exception e) {
				t.RollBack();
				Console.WriteLine(e);
			}
			
		}
		
		[STAThread]
		public static void Main(string[] args) {
			CreatePetShopData createPetShopData = new CreatePetShopData();
			try {
				createPetShopData.CreateData();
			}
			finally {
				petshop.PetShopPersistentManager.Instance().DisposePersistentManager();
			}
			
		}
		
	}
}

